package com.heima.home.mapper;

import com.heima.home.entity.Favorites;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FavoritesMapper {
    @Select("select * from favorites where user_id=#{userId}")
    List<Favorites> findAll(Integer userId);
    @Delete("delete from favorites where property_id=#{propertyId} and user_id=#{userId}")
    int cancelFavorites(Integer propertyId,Integer userId);
    @Insert("insert into favorites (user_id, property_id, created_at) values (#{userId},#{propertyId},#{createdAt})")
    int addFavorites(Favorites favorites);
    
    @Select("select count(*) from favorites where user_id = #{userId}")
    Integer countByUserId(Integer userId);
}
